package pack3;

import pack3.utils.Utils;

import java.util.Arrays;

public class SelectSort {
    public static void main(String[] args) {
        int []arr=new int[]{7,5,6,9,10,1,3,7,4,3,2};
        selectSort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void selectSort(int[]arr){
        for (int i = 0; i < arr.length; i++) {
            int minIndex=i;
            for (int j = i-1; j <arr.length; j++) {
                if(arr[j]<arr[minIndex]){
                    minIndex=j;
                }
            }
            if(arr[i]>arr[minIndex]){
                Utils.swap(arr,i,minIndex);
            }
        }
    }
}
